package br.edu.ufcg.splab.techniques.reduction.functions.similarity;

import br.edu.ufcg.splab.generator.TestCase;

public class SymmetricNormalisedCompressionDistance implements DistanceFunction{

	
	public double getSimilarity(TestCase path1, TestCase path2){
		return compare(path1, path2);
	}
	
	
	/**
	 * Applies the symmetric normalised compression distance.
	 * 
	 * @param path1
	 * @param path2
	 * @return the similarity value.
	 */
	private double compare(TestCase path1, TestCase path2) {
		NormalisedCompressionDistance ncd = new NormalisedCompressionDistance();
		double ncd1 = ncd.getSimilarity(path1, path2);
		double ncd2 = ncd.getSimilarity(path2, path1);
		
		return (ncd1 + ncd2)/2.00;
	}
	

	/**
     * Provide a string representation of the similarity function to be written.
     * @return The string representation of the similarity function.
     */
	public String getFunctionName(){
		return "SNCD";
	}
	
}
